<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ taglib  prefix="s"  uri="/struts-tags"%> 
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title></title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link href="css/default.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="js/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="js/themes/icon.css" />
    <script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="js/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="js/locale/easyui-lang-zh_CN.js"></script>
	<style type="text/css">
		input,textarea{
			width:200px;
			border:1px solid #ccc;
			padding:2px;
		}
	</style>
  </head>
  
  <body>
  		
  	<table id="grid"></table>
  	
  	<div id="search" style="padding:5px;height:auto">  
  		<div>
  			客户:   
	        <input name="customerName" id="customerName" class="easyui-validatebox" style="width:100px"  type="text">  
	        创建日期: <input name="startDate" id="startDate" class="easyui-datebox" style="width:80px" type="text">  
	        到: <input name="endDate" id="endDate" class="easyui-datebox" style="width:80px" type="text">  
	         <a href="javascript:void();" class="easyui-linkbutton" iconCls="icon-search" id='btnSearch'>搜索</a>  
	    </div> 
	    <div style="margin-bottom:5px">  
	        <!-- <a href="javascript:void();" class="easyui-linkbutton" iconCls="icon-add" plain="true" id="btnAdd">新增订单</a> -->  
	        <a href="javascript:void();" class="easyui-linkbutton" iconCls="icon-remove" plain="true" id="btnDel">删除</a>  
	    </div>  
	     
	</div>  
	
	
	<!-- 弹出明细窗口 -->
	<div id="dd"></div>
	<div id="win"></div>   
	
  </body>
</html>

<script type="text/javascript">
	$(function(){
		$('#grid').datagrid({
			toolbar:"#search",
		    title:'订单',
		    width:800,
		    height:500,
		    url:'contmaster_search.do',
		    columns:[[
		        {field:'corpcode',title:'帐套代码',width:80},
		        {field:'name',title:'客户',width:200},
		        {field:'summoney',title:'金额',width:60},
		        {field:'createdate',title:'创建日期',width:80,align:'left'},
		        {field:'stateName',title:'状态',width:100}
		    ]],
		    frozenColumns:[[
	                {field:'ck',checkbox:true},
	                {title:'订单编号',field:'contno',width:80,sortable:true}
				]],
		    onDblClickRow: function(rowIndex,rowData){
    			//alert(rowData['contno']);
    			//双击时，显示订单明细
    			shwoDetail(rowData['contno']);
    			//window.open("contmaster_detail.do?contno=C201110280005");
			},
		    pagination:true
		});
		/*
		var pager = $('#grid').datagrid("getPager");
		pager.pagination({
			onRefresh:function(){
				alert('resh');
			}
		});
			*/
		$("#btnDel").click(function(){
			var selected = $('#grid').datagrid('getSelected');
			if (selected){
				$.messager.confirm('系统提示', '确定要删除所选的订单吗?', function(r){
					if (r){
						$.messager.alert('系统提示',selected.contno);
					}
				});
			}else{
				$.messager.alert('系统提示','请选择订单再删除!');
			}
		});
		
		$("#btnSearch").click(function(){
			$('#grid').datagrid({
				url:'contmaster_search.do',
			    queryParams:{
			    	customerName:$("#customerName").val(),
			    	startDate:$("#startDate").datebox("getValue"),
			    	endDate:$("#endDate").datebox("getValue")
			    },
			});
			$('#grid').datagrid("load");
		});
		/*
		var pg = $("#grid").datagrid("getPager");
		if(pg)
		{
		   $(pg).pagination({
		       onRefresh:function(pageNumber,pageSize){
		           alert(pageNumber);
		           alert(pageSize);
		        },
		       onChangePageSize:function(){
		           alert('pagesize changed');
		        },
		       onSelectPage:function(pageNumber,pageSize){
		           alert(pageNumber);
		           alert(pageSize);
		        }
		   });
		}
		*/
		
		
		 
		
		//$('#win').window("close");
		$("#btnAdd").click(function(){
			$('#win').window({  
			    width:700,  
			    height:350,  
			    modal:true
			});  
			$('#win').window('refresh','<%=basePath%>/contmaster_add.do?contno='+contno+"&random="+Math.random());
		});
	});
	
	function shwoDetail(contno){
		$('#win').window({  
			title:'订单',
		    width:700,  
		    height:450,  
		    maximizable:false,
		    collapsible:false,
		    minimizable:false,
		    modal:true
		});  
		$('#win').window('refresh','<%=basePath%>/contmaster_detail.do?contno='+contno+"&random="+Math.random());
	}
	
	
	
</script>	
